<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head th:replace="common/fragment::top">

</head>

<body>
<div class="lyear-layout-web">
  <div class="lyear-layout-container">
    <!--左侧导航-->
    <div th:replace="common/fragment::leftmenu"></div>
    <!--End 左侧导航-->

    <!--头部信息-->
    <div th:replace="common/fragment::header"></div>
    <!--End 头部信息-->

    <!--页面主要内容-->
    <main class="lyear-layout-content">

      <div class="container-fluid">
        <div class="row">
          <div class="col-lg-12">
            <div class="card">
              <div class="card-toolbar clearfix">
                <form action="" class="pull-right search-bar" method="get" role="form">
                  <div class="input-group">


                    <span class="input-group-btn">
                                              <button class="btn btn-primary" id="keyword-find-btn"
                                                      onclick="keywordsearch()"
                                                      type="button">搜索</button>
                                            </span>

                  </div>
                </form>


              </div>
              <div class="card-body">
                <div class="table-responsive">
                  <table class="table table-bordered">
                    <thead>
                    <tr>
                      <th>序号</th>
                      <th hidden="hidden">id</th>
                      <th>订单号</th>
                      <th>顾客</th>
                      <th>状态</th>
                      <!--                                            <th>包装</th>-->
                      <th>生成日期</th>
                      <th>要货日期</th>
                      <th>总金额</th>
                      <th>备注</th>
                      <th>操作</th>
                    </tr>
                    </thead>
                    <tbody>
                    <tr th:each="sell:${selllist}">

                      <td th:text="${sellStat.index+1}"></td>
                      <td hidden="hidden" th:text="${sell.id}"></td>

                      <td th:text="${sell.name}"></td>
                      <td th:text="${sell.custPO.name}">顾客</td>

                      <td th:text="${sellstatus[sell.status]}"></td>
                      <td th:text="${#dates.format(sell.createTime, 'yyyy-MM-dd')}"></td>

                      <td th:text="${#dates.format(sell.need, 'yyyy-MM-dd')}"></td>
               <th class="total" th:text="${#numbers.formatDecimal(sell.sumSellDetail,1,'COMMA',2,'POINT')}">总金额</th>
                      <td th:text="${sell.comment}"></td>

                      <td>
                        <div class="btn-group">
                          <a class="btn btn-xs btn-default editsell"
                             data-toggle="tooltip"
                             th:href="@{${sell.id}}" title="查看明细">
                            <i class="mdi mdi-pencil"></i>
                          </a>
<!--                          <a class="btn btn-xs btn-default forbidden"-->
<!--                             data-toggle="tooltip"-->

<!--                             th:href="@{${pur.id}}" title="禁用">-->
<!--                            <i class="mdi mdi-alert-outline"></i>-->
<!--                          </a>-->
                        </div>
                      </td>
                    </tr>

                    </tbody>
                  </table>
                </div>

              </div>
            </div>
          </div>

        </div>

      </div>
    </main>
    <!--End 页面主要内容-->
    <!--End 页面主要内容-->
  </div>
</div>
<div th:replace="common/fragment::tail-script"></div>
<!--<script type="text/javascript" th:inline="javascript">-->
<!--  /*<![CDATA[*/-->
<!--  var max = /*[[${maxSumOfDateInYear}]]*/ 20;-->
<!--  alert(max);-->
<!--  /*]]>*/-->
<!--</script>-->

<script type="text/javascript">


  $(document).ready(function () {
// 新建订单按钮
//     $('#addsell-btn').click(function (e) {
//       let select = $('#status-select').val()
//       if(select===''){
//         select=-999
//       }
//         window.location.href="/sell/addsell.do"
//       e.preventDefault();
//     });
// END新建订单按钮

// 按状态搜索
/*    $('#keyword-find-btn').click(function () {
      let status = $('#status-select').val()
      window.location.href = "/sell/selllist.do?status="+status
    });*/
// END 按状态搜索

// 查看订单
    $('.editsell').each(function (i,e) {
      $(this).click(function (ev) {
        let id = $(this).attr('href')
        // 发生页面跳转
        window.location.href="/purchase/shortagedetail.do?sellid="+id
        ev.preventDefault()
      });
    });
// END 查看订单

// 生成总金额
    $('.editsell').each(function (i,e) {
      $(this).click(function (ev) {
        let id = $(this).attr('href')
        // 发生页面跳转
        window.location.href="/purchase/shortagedetail.do?sellid="+id
        console.log()
        ev.preventDefault()
      });
    });
// END 总金额

  });

</script>
</body>
</html>